package com.drojian.thread.waitandnotify;


public class Cookie extends Thread{
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.lock) {
                if(Desk.count == 0){
                    break;
                }else{
                    if(Desk.foodFlag == 1){
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }else{
                        System.out.println("厨师做了一碗");
                        Desk.foodFlag = 1;
                        Desk.lock.notifyAll();
                    }
                    }

            }
        }
    }
}
